<% layout('/layouts/default.html', {title: '活动管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('活动管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('kj:kjActivity:edit')){ %>
					<a href="${ctx}/kj/kjActivity/form" class="btn btn-default btnTool" title="${text('新增活动')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-navicon"></i> <span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${kjActivity}" action="${ctx}/kj/kjActivity/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">

			<div class="form-group">
				<label class="control-label">${text('所属城市')}：</label>
				<div class="control-inline">
					<#form:listselect id="testUser3" title="城市选择"
					path="kjCity.id"   labelPath="kjCity.name"
					url="${ctx}/kj/kjCity/kjCitySelect?pageSize=1000" allowClear="false"
					checkbox="false" itemCode="id" itemName="name"/>
				</div>
			</div>
			<div class="form-group">
					<label class="control-label">${text('活动名')}：</label>
					<div class="control-inline">
						<#form:input path="name" autocomplete="off" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('联系人')}：</label>
					<div class="control-inline">
						<#form:input path="leader" autocomplete="off" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('活动状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="activityStatus" dictType="activity_status" blankOption="true" class="form-control width-120 "/>
					</div>
				</div>
			<div class="form-group">
				<label class="control-label">${text('活动回显')}：</label>
				<div class="control-inline width-120">
					<#form:select path="status" dictType="delete_status"  defaultValue="0" blankOption="false" class="form-control width-120 "/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('审核状态')}：</label>
				<div class="control-inline width-120">
					<#form:select path="activityAudit" dictType="activity_audit" blankOption="true" class="form-control width-120 "/>
				</div>
			</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("活动名")}', name:'name', index:'a.name', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/kj/kjActivity/form?id='+row.id+'" class="btnList" data-title="${text("编辑活动")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("所属城市")}', name:'kjCity.name', index:'c.name', width:100, align:"left"},
		{header:'${text("联系人")}', name:'leader', index:'c.leader', width:100, align:"left"},
		{header:'${text("联系电话")}', name:'leaderPhone', index:'c.leader_phone', width:150, align:"left"},
		{header:'${text("报名开始时间")}', name:'signStartTime', index:'a.sign_start_time', width:150, align:"center"},
		{header:'${text("报名结束时间")}', name:'signEndTime', index:'a.sign_end_time', width:150, align:"center"},
		{header:'${text("活动开始时间")}', name:'startTime', index:'a.start_time', width:150, align:"center"},
		{header:'${text("活动结束时间")}', name:'endTime', index:'a.end_time', width:150, align:"center"},
		{header:'${text("活动状态")}', name:'activityStatus', index:'a.activity_status', width:150, align:"left", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('activity_status')}, val, '未知', true);
		}},
		{header:'${text("审核状态")}', name:'activityAudit', index:'a.activity_audit', width:150, align:"left", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('activity_audit')}, val, '未知', true);
			}},
		{header:'${text("备注")}', name:'remarks', index:'a.remarks', width:250, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			if(row.status==='0'){
					<% if(hasPermi('kj:kjActivity:edit')){ %>
						actions.push('<a href="${ctx}/kj/kjActivity/form?id='+row.id+'" class="btnList" title="${text("编辑活动")}"><i class="fa fa-pencil"></i></a>&nbsp;');
					    actions.push('<a href="${ctx}/kj/kjActivity/delete?id='+row.id+'" class="btnList" title="${text("删除活动")}" data-confirm="${text("确认要删除该活动吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
					<% } %>
			};
			actions.push('<a href="javascript:" class="btnMore" title="${text("更多操作")}"><i class="fa fa-chevron-circle-right"></i></a>&nbsp;');
			actions.push('<div class="moreItems">');
			actions.push('<a href="${ctx}/kj/kjActivity/copy?id=' + row.id + '" class="btn btn-default btn-xs btnList" title="${text("复制活动")}" data-confirm="${text("确认要复制该活动吗？")}"><i class="fa"></i> ${text("复制活动")}</a>&nbsp;');
			if(row.status==='0'){
					// actions.push('<a href="${ctx}/kj/kjActivityJob/list?activityId='+row.id+'" class="btn btn-default btn-xs btnList" title="${text("活动岗位")}"><i class="fa"></i> ${text("活动岗位")}</a>&nbsp;');
				<% if(hasPermi('kj:kjActivity:audit')){ %>
		            if(row.activityAudit=='0'){
	                actions.push('<a href="${ctx}/kj/kjActivity/form?action=audit &id='+row.id+' " class="btn btn-default btn-xs btnList" title="${text("审核活动")}"><i class="fa"></i> ${text("审核活动")}</a>&nbsp;');
	                }
		        <% }%>
				<% if(hasPermi('kj:kjActivityJob:view')){ %>
					if(row.activityAudit=='1') {
						actions.push('<a href="${ctx}/kj/kjActivity/batchAddIntegral?activityId='+row.id+'" class="btn btn-default btn-xs btnList" title="${text("批量发放积分")}"  data-confirm="确认批量发放积分吗？"><i class="fa"></i> ${text("发放积分")}</a>&nbsp;');
					}
				<% }%>
			}
            actions.push('</div>');
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});

$('#btnExport').click(function(){
	js.ajaxSubmitForm($('#searchForm'), {
		url: '${ctx}/kj/kjActivity/exportData',
		downloadFile: true
	});
});
</script>
